package ace.cmp.data.methodname.sql.mybatisplus.test.dao.mapper;

import ace.cmp.data.methodname.sql.mybatisplus.core.annotations.InjectMethodNameToSql;
import ace.cmp.data.methodname.sql.mybatisplus.test.dao.entity.CASUserOnlyNameView;
import ace.cmp.data.methodname.sql.mybatisplus.test.dao.entity.CasUser;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import java.time.LocalDateTime;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

/**
 * @author caspar
 * @date 2023/2/15 13:42
 */
@Mapper
public interface CasUserMapper extends BaseMapper<CasUser> {

  List<CasUser> findByMobile(@Param("mobile") String mobile);

  // selectAllAndFilterMultiAndSortMultiAndLimitAndDistinct
  List<CasUser>
      findTop10DistinctByMobileAndNameContainingAndIdEndWithAndRowVersionOrderByNameAscIdDesc(
          @Param("mobile") String mobile,
          @Param("name") String name,
          @Param("id") String id,
          @Param("rowVersion") Integer rowVersion);

  CasUser findTop10DistinctByOrderByNameAscIdDesc();

  Integer countAllBy();

  Integer countByMobileEndWithAndCreateTimeBetween(
      @Param("mobile") String mobile,
      @Param("createTimeStart") LocalDateTime createTimeStart,
      @Param("createTimeEnd") LocalDateTime createTimeEnd);

  Integer countTop10DistinctByMobileAndCreateTimeBetween(
      @Param("mobile") String mobile,
      @Param("createTimeStart") LocalDateTime createTimeStart,
      @Param("createTimeEnd") LocalDateTime createTimeEnd);

  Boolean existsAllBy();

  Integer existsByMobileEndWithAndCreateTimeBetween(
      String mobile, LocalDateTime createTimeStart, LocalDateTime createTimeEnd);

  Integer existsTop10DistinctByMobileAndCreateTimeBetween(
      String mobile,
      @Param("createTimeStart") LocalDateTime createTimeStart,
      LocalDateTime createTimeEnd);

  Integer deleteAllBy();

  Integer deleteByMobileEndWithAndCreateTimeBetween(
      @Param("mobile") String mobile,
      @Param("createTimeStart") LocalDateTime createTimeStart,
      @Param("createTimeEnd") LocalDateTime createTimeEnd);

  Integer deleteTop10DistinctByMobileAndCreateTimeBetween(
      @Param("mobile") String mobile,
      @Param("createTimeStart") LocalDateTime createTimeStart,
      @Param("createTimeEnd") LocalDateTime createTimeEnd);

  Integer deleteTop3ByMobileAndCreateTimeBetween(
      @Param("mobile") String mobile,
      @Param("createTimeStart") LocalDateTime createTimeStart,
      @Param("createTimeEnd") LocalDateTime createTimeEnd);

  @InjectMethodNameToSql
  List<CasUser> findAnnEnableByMobile(@Param("mobile") String mobile);

  @InjectMethodNameToSql(enable = false)
  List<CasUser> findAnnDisableByMobile(@Param("mobile") String mobile);

  @InjectMethodNameToSql
  List<CasUser> findTop2ByMobileContains(@Param("mobile") String mobile);

  @InjectMethodNameToSql
  List<CasUser> findTop10ByMobileContains(String mobile);

  @InjectMethodNameToSql
  List<CASUserOnlyNameView> findIdAndNameByMobileContains(String mobile);
}
